package com.gxa.modules.pc.hospital.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Query;
import com.gxa.modules.model.entity.hospital.Title;
import com.gxa.modules.pc.hospital.mapper.DoctorLabelMapper;
import com.gxa.modules.pc.hospital.service.DoctorLabelService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 医生标签 服务实现类
 * </p>
 *
 * @author gxa
 * @since 2022-11-12 05:04:59
 */
@Service
public class DoctorLabelServiceImpl extends ServiceImpl<DoctorLabelMapper, Title> implements DoctorLabelService {

    @Autowired
    private DoctorLabelMapper doctorLabelMapper;
    @Override
    public PageUtils queryByPage(Map<String,Object> params) {
        String labelName = (String)params.get("name");
        IPage<Title> page = this.page(new Query<Title>().getPage(params),
                new QueryWrapper<Title>().likeRight(StringUtils.isNotEmpty(labelName),
                        "titlename", labelName));

        return new PageUtils(page);
    }

    @Override
    public void addTitle(Map<String, Object> params) {
        Title title = new Title();
        title.setName((String) params.get("name"));
        title.setIsDelete(0);
        title.setCreateTime(new Date(System.currentTimeMillis()));
        title.setPrice(Double.valueOf((String) params.get("price")));
        title.setTitledescribe((String) params.get("titledescribe"));
        title.setState(0);
        doctorLabelMapper.insert(title);
    }

    @Override
    public void deleteByList(int[] list) {
            doctorLabelMapper.deleteByList(list);
    }


}
